package org.lecric.wind44.client.dialog;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;

/**
 * @author Lecric
 * @deprecated Use {@link Window#prompt(String, String)} instead
 */
@Deprecated
public class NewNameDialog extends DialogBox
{
	private Button okButton;
	private TextBox textBox;

	public NewNameDialog(String title)
	{
		setText(title);
		VerticalPanel vpanel = new VerticalPanel();
		HorizontalPanel hpanel1=new HorizontalPanel();
		hpanel1.add(new Label("Name"));
		textBox = new TextBox();
		hpanel1.add(textBox);
		vpanel.add(hpanel1);
		HorizontalPanel hpanel2=new HorizontalPanel();
		okButton = new Button("OK");
		ClickHandler closeHandler = new ClickHandler(){
			@Override
			public void onClick(ClickEvent event) {
				hide();
			}
		};
		okButton.addClickHandler(closeHandler);
		hpanel2.add(okButton);
		Button cancelButton = new Button("Cancel");
		cancelButton.addClickHandler(closeHandler);
		hpanel2.add(cancelButton);
		vpanel.add(hpanel2);
		add(vpanel);
		textBox.setFocus(true);
		center();
	}

	public Button getOkButton() {
		return okButton;
	}

	public String getName() {
		return textBox.getText();
	}
	
	public void setName(String name)
	{
		textBox.setText(name);
	}
}
